#include <iostream>
#include <string>
using namespace std;
int table[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
bool is_leap_year(int cur_year)
{
	return (cur_year%4==0 && cur_year%100) || (cur_year%400==0);
}
bool is_palindrome(string str)
{
	int left=0;
	int right=str.size()-1;
	while(left<=right)
	{
		if (str[left++]!=str[right--])
			return false;
	}
	return true;
}

string my_to_string(int cur_year,int cur_month,int cur_day)
{
	string year=to_string(cur_year);
	string month;
	if (cur_month<=9)
		month='0'+to_string(cur_month);
	else
		month=to_string(cur_month);
	string day;
	if (cur_day<=9)
		day='0'+to_string(cur_day);
	else
		day=to_string(cur_day);
	string ret=year+month+day;
	return ret;
}
int do_enum(string& s_begin,string& s_end)
{
	int sum=0;
	int begin_year=stoi(string(s_begin,0,4));
	int begin_month=stoi(string(s_begin,4,2));
	int begin_day=stoi(string(s_begin,6,2));
	int end_year=stoi(string(s_end,0,4));
	int end_month=stoi(string(s_end,4,2));
	int end_day=stoi(string(s_end,6,2));
	
	int cur_year=begin_year;
	int cur_month=begin_month;
	int cur_day=begin_day;
	
	while(cur_year!=end_year && cur_month!=end_month&&cur_day!=begin_day)
	{
		if (is_palindrome(my_to_string(cur_year,cur_month,cur_day)))
			sum++;
		cur_day++;
		if (cur_month==2&&is_leap_year(cur_year))
				table[2]=29;
		else
				table[2]=28;
		if (cur_day>table[cur_month])
		{
			cur_day=0;
			cur_month++;
			if (cur_month==12)
			{
				cur_month=0;
				cur_year++;
			}
			if (cur_month==2&&is_leap_year(cur_year))
				table[2]=29;
			else
				table[2]=28;
		}
	}
	return sum;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0); 
	string s_begin,s_end;
	cin>>s_begin>>s_end; 
	cout<<do_enum(s_begin,s_end);
	return 0;
}
